import time

from selenium.webdriver.common.by import By

from Base.BasePage import BasePage


class HTLogin(BasePage):
    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.username = (By.ID, "username")
        self.password = (By.ID, "password")
        self.valicode = (By.ID, "valicode")
        self.login = (By.XPATH, '//*[@id="loginForm"]/div[4]/input')
        self.success = (By.XPATH, '//*[@id="breadcrumbs"]/div')

    def HTLogin(self, phone, password, valicode):
        self.base_clear_input(self.username, phone)
        self.base_clear_input(self.password, password)
        self.base_clear_input(self.valicode, valicode)
        self.click_element(self.login)

    def assert_HTLogin_success(self):
        time.sleep(2)
        # self.switch_window(self.success)
        re = self.get_element(self.success).text
        return re
